cmake_minimum_required(VERSION 2.8)

message("-- Project: net")

file(GLOB net_src "*.cpp")
file(GLOB net_protocol_src "protocol/*.c")
file(GLOB http_protocol_src "http_protocol/*.cpp")
file(GLOB net_modbus_protocol_src "protocol/modbus/*.c")

add_library(net SHARED ${net_src} 
	${net_protocol_src} 
	${net_modbus_protocol_src}
	${http_protocol_src}) 


set_target_properties(net PROPERTIES OUTPUT_NAME "net")

target_link_libraries(net stdcrt)

include_directories(
	${PROJECT_SOURCE_DIR}/include
	${PROJECT_SOURCE_DIR}/crt
	${PROJECT_SOURCE_DIR}/extensions/include
	${by3rd_library_include})


if (${WIN_OS})

	target_link_libraries(net ws2_32)
	set(CMAKE_SHARED_LINKER_FLAGS 
		"${CMAKE_SHARED_LINKER_FLAGS} /DEF:${PROJECT_SOURCE_DIR}/net/dllexports.def")

else()

	include_directories(
		/usr/local/include
		/opt/include
		/usr/include)


	add_definitions("-D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8")
	add_definitions("-D__GCC_HAVE_SYNC_VAL_COMPARE_AND_SWAP_1")
	add_definitions("-D__GCC_HAVE_ATOMIC_FETCH_SUB_1")
	add_definitions("-D__GCC_HAVE_ATOMIC_FETCH_SUB_4")
	add_definitions("-D__GCC_HAVE_ATOMIC_FETCH_ADD_1")
	add_definitions("-D__GCC_HAVE_ATOMIC_FETCH_ADD_4")
	add_definitions("-D__GCC_HAVE_ATOMIC_LOAD_4")

	set_target_properties(net PROPERTIES COMPILE_FLAGS ${dynamic})
	set_target_properties(net PROPERTIES COMPILE_FLAGS ${compile})
	set_target_properties(net PROPERTIES LINK_FLAGS ${r_path})

	if(${LINUX_OS})
		target_link_libraries(net dl)
	endif()

	if(${UNIX_OS})
		target_link_libraries(net)
	endif()


endif()








